Passed
Pull Request — master (#79)
by Mathieu
01:24
created

Quote.getAvailableStatus   A

Complexity

Conditions 1

Size

Total Lines 8
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 8
c 0
b 0
f 0
rs 10
cc 1
1
import {Entity, Column, PrimaryGeneratedColumn, ManyToOne} from 'typeorm';
2
import {Customer} from '../Customer/Customer.entity';
3
import {Project} from '../Project/Project.entity';
4
import {User} from '../User/User.entity';
5
6
export enum QuoteStatus {
7
  DRAFT = 'draft',
8
  SENT = 'sent',
9
  REFUSED = 'refused',
10
  ACCEPTED = 'accepted',
11
  CANCELED = 'canceled'
12
}
13
14
@Entity()
15
export class Quote {
16
  @PrimaryGeneratedColumn('uuid')
17
  private id: string;
18
19
  @Column('enum', {enum: QuoteStatus, nullable: false})
20
  private status: QuoteStatus;
21
22
  @Column({type: 'varchar', nullable: false, unique: true})
23
  private quoteId: string;
24
25
  @Column({type: 'timestamp', default: () => 'CURRENT_TIMESTAMP'})
26
  private createdAt: Date;
27
28
  @ManyToOne(type => User, {nullable: false})
29
  private owner: User;
30
31
  @ManyToOne(type => Customer, {nullable: false})
32
  private customer: Customer;
33
34
  @ManyToOne(type => Project, {nullable: true})
35
  private project: Project;
36
37
  constructor(
38
    quoteId: string,
39
    status: QuoteStatus,
40
    owner: User,
41
    customer: Customer,
42
    project?: Project | null
43
  ) {
44
    this.quoteId = quoteId;
45
    this.status = status;
46
    this.owner = owner;
47
    this.customer = customer;
48
    this.project = project;
49
  }
50
51
  public getId(): string {
52
    return this.id;
53
  }
54
}
55